package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.Menu_managementDao;
import com.itheima.domain.Menu_management;
import com.itheima.domain.PageResult;
import com.itheima.domain.Result;
import com.itheima.service.Menu_managementService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class Menu_managementImpl implements Menu_managementService {

    @Autowired
    private Menu_managementDao menuDao;

    @Override
    //删除

    public void delete(Integer id) throws RuntimeException{
        //查询当前检查项是否和检查组关联

        menuDao.deleteById(id);
    }


    @Override
    public void save(Menu_management menu_management) {
        menuDao.save(menu_management);
    }

    @Override
    public List<Menu_management> findAll() {
        return menuDao.findAll();
    }

    @Override
    public Menu_management findById(Integer userId) {
        return menuDao.findById(userId);
    }

    @Override
    public void updateMenu(Menu_management menu) {
        menuDao.updateMenu(menu);
    }

    @Override
    public void edit(Menu_management menu_management) {
         menuDao.edit(menu_management);
    }

    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<Menu_management> page = menuDao.selectByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public List<Menu_management> EstimateFindAll() {
        return menuDao.EstimateFindAll();
    }
}
